package cathttp

// CatRouting 路由类
type CatRouting struct {
	Verify *map[string]*CatVerify
	http   *CatHTTP
	path   string
}

// AddGET 添加Get协议路由
func (R *CatRouting) AddGET(Path string, ServeHTTP func(Value *CatValue)) {
	R.http.HandlePath[R.path+Path] = CatHandle{
		Verify:       R.Verify,
		ServeHTTP:    ServeHTTP,
		ProtocolType: "GET",
	}
}

// AddPOST 添加Post协议路由
func (R *CatRouting) AddPOST(Path string, ServeHTTP func(Value *CatValue)) {
	R.http.HandlePath[R.path+Path] = CatHandle{
		Verify:       R.Verify,
		ServeHTTP:    ServeHTTP,
		ProtocolType: "POST",
	}
}

// AddRegExpGET 添加正则Get协议路由
func (R *CatRouting) AddRegExpGET(Path string, ServeHTTP func(Value *CatValue)) {
	R.http.HandleRegExp[R.path+Path] = CatHandle{
		Verify:       R.Verify,
		ServeHTTP:    ServeHTTP,
		ProtocolType: "GET",
	}
}

// AddRegExpPOST 添加正则Post协议路由
func (R *CatRouting) AddRegExpPOST(Path string, ServeHTTP func(Value *CatValue)) {
	R.http.HandleRegExp[R.path+Path] = CatHandle{
		Verify:       R.Verify,
		ServeHTTP:    ServeHTTP,
		ProtocolType: "POST",
	}
}
